package com.xzj.springmvc.controller;

import com.xzj.spring.annotation.Autowired;
import com.xzj.springmvc.annotation.PostMapping;
import com.xzj.springmvc.annotation.RequestMapping;
import com.xzj.springmvc.annotation.RequestParam;
import com.xzj.springmvc.annotation.RestController;
import com.xzj.springmvc.entity.po.User;
import com.xzj.springmvc.entity.vo.UserVO;
import com.xzj.springmvc.service.IUserService;

import java.util.Base64;

/**
 * @ProjectName: SpringDemo
 * @Package: com.xzj.springmvc.controller
 * @ClassName: HelloController
 * @Author: xzj
 * @Description:
 * @Date: 2022/7/14 16:48
 * @Version: 1.0
 */
@RestController("myHelloController")
@RequestMapping("/hello")
public class HelloController {

    @Autowired
    IUserService userService;

    @PostMapping("/hello")
    public void hello(@RequestParam("user") UserVO userVO) {
        User user = new User();
        user.setUsername(userVO.getUsername());
        user.setPassword(Base64.getEncoder().encodeToString(userVO.getPassword().getBytes()));
        System.out.println(userVO);
        System.out.println(user);
        userService.logging(user);
    }

}
